 <template>
  <div>
    <div class="dialogPop">
      <el-dialog :visible.sync="updataData.dialogUpdata" :before-close="handleClose" size="tiny">
        <p class="dialog-title">修改视角</p>
        <el-form :model="updataData" :rules="rules" ref="updataData" label-width="90px">
          <el-row :gutter="20">
            <el-col :span="22">
              <el-form-item label="视角名称:" prop="sAngleView">
                <el-popover placement="top-start" trigger="focus"
                                content="字符长度不大于4个">
                     <el-input v-model="updataData.sAngleView" slot="reference" :maxlength="4" placeholder="请输入视角名称"></el-input>
                   </el-popover>
              </el-form-item>
              
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <p class="btn">
            <el-button @click="resetForm('updataData')">取 消</el-button>
            <el-button type="primary" @click="updataBtn('updataData')" :loading="loadingBtn">确 定</el-button>
          </p>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import { updateAngleView } from 'api/deviceManagement';
export default {
    props: {
        updataData: {
            default() {
                return {
                    dialogUpdata: false // 默认不显示
                }
            },
            required: true
        }
    },
    data() {
        return {
            rules: {
                sAngleView: [
                    { required: true, message: '请输入视角名称', trigger: 'blur' },
                    { pattern: /^[^\s]+$/, message: '请勿输入空格', trigger: 'blur' }
                ]
            },
            loadingBtn: false
        }
    },
    methods: {
    // 确定按钮
        updataBtn(addTeaPop) {
            this.$refs[addTeaPop].validate((valid) => {
                if (valid) {// 验证通过
                    this.loadingBtn=true;
                    let pId=this.updataData.pId;
                    let sAngleView=this.updataData.sAngleView;
                    updateAngleView(pId, sAngleView).then(res => {
                        this.loadingBtn=false;
                        this.$message({
                            type: 'success',
                            message: '修改成功!'
                        });
                        this.$emit('searchList');// 更新列表
                        this.handleClose();
                        
                    }).catch(() => {
                        this.loadingBtn=false;
                    })
                } else {
                    return false;
                }
            });
        },
        handleClose() {
            this.delDialogAddTea();
        },
    // 取消按钮 
        resetForm(dataForm) {
            this.$refs[dataForm].resetFields();
            this.delDialogAddTea();
        },
    // 还原弹窗信息
        delDialogAddTea() {
            this.updataData.dialogUpdata = false;
            this.updataData.eyeName = '';
        }
  
       
    }
}
</script>
<style lang="scss" scoped>
@import '../style/dialog.scss';
</style>


